import code
import codecs
import csv,os

filename='C:/Users/robinwb/Desktop/582.csv'
outfile='C:/Users/robinwb/Desktop/582new.csv'
# with open(filename) as f:
#     reader = csv.reader(f)
#     print(list(reader))
out = open(outfile, 'w')
csv_writer = csv.writer(out)
# out.write(codecs.BOM_UTF8)
csv_reader = csv.reader(open(filename, encoding='utf-8'))
for row in csv_reader:
    courses=row[3]
    if courses!='course_id':
        course_ids=courses.split('&')
        for cid in course_ids:
            list=[]
            list.append(row[0])
            list.append(row[1])
            list.append(row[2])
            list.append(cid)
            list.append(row[4])
            print(list)
            #csv_writer.writerow(list)






